package com.x.crm.dao;

import com.x.crm.model.FixtureCar;
import com.x.crm.model.FollowUp;
import com.x.framework.dao.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class FixtureCarDao extends BaseDao{


	private final static String baseSelectFixtureCarListSql = "SELECT * FROM  CRM_FIXTURE_CAR  I " +
			"WHERE 1=1 ";

	public List<FixtureCar> selectFixtureCarList(FixtureCar fixtureCar) throws Exception {
		StringBuilder sb = new StringBuilder(baseSelectFixtureCarListSql);
		List<Object> params = new ArrayList<Object>();
		searchBasicCondition(fixtureCar, sb, params);
		sb.append(" ORDER BY I.FIXTURE_CREATE_TIME  DESC");
		return this.queryForList(sb.toString(), FixtureCar.class, params, fixtureCar);
	}


	private void searchBasicCondition(FixtureCar fixtureCar, StringBuilder sb, List<Object> params) {
		if (this.isString(fixtureCar.getFollowFixtureId())) {
			sb.append("AND I.FOLLOW_FIXTURE_ID = ? ");
			params.add(fixtureCar.getFollowFixtureId());
		}
	}


}
